package com.feib.soeasy.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.feib.soeasy.dao.CommissionCodeTableDao;
import com.feib.soeasy.model.CommissionCodeTable;
import com.feib.soeasy.pagination.PaginatedList;
import com.feib.soeasy.service.CommissionCodeTableService;

@Service("commissionCodeTableService")
public class CommissionCodeTableServiceImpl extends BaseServiceImpl implements CommissionCodeTableService {

    @Resource(name="commissionCodeTableDao")
    private CommissionCodeTableDao commissionCodeTableDao;

    @Override
    public List<CommissionCodeTable> modifyCommissionCodeTable(
                    List<CommissionCodeTable> commissionCodeTables) {

        List<CommissionCodeTable> result = new ArrayList<CommissionCodeTable>();

        for(Iterator<CommissionCodeTable> i=commissionCodeTables.iterator();
        i.hasNext();)
        {
            CommissionCodeTable commissionCodeTable = (CommissionCodeTable)i.next();
            commissionCodeTable = commissionCodeTableDao.save(commissionCodeTable);
            result.add(commissionCodeTable);
        }

        return result;
    }

    @Override
    public PaginatedList<CommissionCodeTable> queryCommissionCodeTable(
                    String qryCode, String qryCodeName) {
        // TODO Auto-generated method stub
        PaginatedList<CommissionCodeTable> paginatedList = 
            new PaginatedList<CommissionCodeTable>();

        List<CommissionCodeTable> list = 
            commissionCodeTableDao.queryCommissionCodeTables(qryCode, qryCodeName);

        paginatedList.setPaginatedList(list);

        return paginatedList;
    }
    
    public List<CommissionCodeTable> queryAll()
    {
        return this.commissionCodeTableDao.findAll();
    }

}
